//
//  XDLMTotalIncomeViewController.m
//  xindailianmeng
//
//  Created by 许佳奇 on 17/2/23.
//  Copyright © 2017年 xindailianmeng.cn. All rights reserved.
//*********累计收益

#import "XDLMTotalIncomeViewController.h"
#import "XDLMTotallIncomeTableViewCell.h"
#import "ZHRTBasicMethod.h"
#import "AFHTTPSessionManager+POST.h"
#import "XDLMUIFactory.h"
#define TEXTCOLOR [UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1]
@interface XDLMTotalIncomeViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation XDLMTotalIncomeViewController
{
    UITableView *_table;
    UILabel *_numberLab;//编号Lab
    UILabel *_persentLab;//利率Lab
    UILabel *_expectLab;//预期年华Lab
    UILabel *_monthLab;//月份Lab
    
    UILabel *_limitLab;//
    UILabel *_moneyLab;//金额Lab;
    UILabel *_leftLab;//剩余磕头金额Lab

}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"累计收益";
    [self addviews];

    // Do any additional setup after loading the view.
}
- (void)addviews
{
    _table = [[UITableView alloc] initWithFrame:kScreenB style:UITableViewStyleGrouped];
    _table.dataSource = self;
    _table.delegate = self;
    _table.tableHeaderView = [self setTopView];
    [_table registerClass:[XDLMTotallIncomeTableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:_table];
}
#pragma mark TableViewDelegate && DataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    XDLMTotallIncomeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50*kscale;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}
- (UIView *)setTopView
{
    UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (245-64)*kscale)];
    UIView *topOne = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (235-64)*kscale)];
    UIImageView *oneBackImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"jianbian"]];
    oneBackImg.frame = topOne.frame;
    [topOne addSubview:oneBackImg];
    [topView addSubview:topOne];
    
    _persentLab = [self createLabelWithFrame:CGRectMake(0, 32*kscale, kScreenW, 36*kscale) text:@"8.06元" textFont:[UIFont systemFontOfSize:38] textColor:[UIColor colorWithRed:146.0/255.0 green:99.0/255.0 blue:.0/255.0 alpha:1]];
//    _persentLab.text = [NSString stringWithFormat:@"%.2f%%",[self.model.rate floatValue]/100];
    _persentLab.attributedText = [self changeLabelWithText:_persentLab.text];
    [topOne addSubview:_persentLab];
    
    _expectLab = [self createLabelWithFrame:CGRectMake(0, 75*kscale, kScreenW, 15*kscale) text:@"累计收益" textFont:[UIFont systemFontOfSize:12] textColor:[UIColor colorWithRed:64.0/255.0 green:46.0/255.0 blue:6.0/255.0 alpha:1]];
    [topOne addSubview:_expectLab];
    
    //三条线
    UILabel *lineLab = [self createLabelWithFrame:CGRectMake(0, (183-64)*kscale, kScreenW, 1) text:nil textFont:nil textColor:[UIColor colorWithRed:218.0/255.0 green:209.0/255.0 blue:179.0/255.0 alpha:1]];
    lineLab.backgroundColor = [UIColor colorWithRed:218.0/255.0 green:209.0/255.0 blue:179.0/255.0 alpha:0.5];
    [topOne addSubview:lineLab];
    
    UILabel *shuLineLab = [self createLabelWithFrame:CGRectMake(kScreenW/3, (193-64)*kscale, 1, 34*kscale) text:nil textFont:nil textColor:[UIColor colorWithRed:218.0/255.0 green:209.0/255.0 blue:179.0/255.0 alpha:0.5]];
    shuLineLab.backgroundColor = [UIColor colorWithRed:218.0/255.0 green:209.0/255.0 blue:179.0/255.0 alpha:1];
    [topOne addSubview:shuLineLab];
    
    UILabel *shuLineLabTwo = [self createLabelWithFrame:CGRectMake(kScreenW/3*2, (193-64)*kscale, 1, 34*kscale) text:nil textFont:nil textColor:[UIColor colorWithRed:218.0/255.0 green:209.0/255.0 blue:179.0/255.0 alpha:0.5]];
    shuLineLabTwo.backgroundColor = [UIColor colorWithRed:218.0/255.0 green:209.0/255.0 blue:179.0/255.0 alpha:1];
    [topOne addSubview:shuLineLabTwo];
    
    UILabel *hengLineLab = [self createLabelWithFrame:CGRectMake(0, 171*kscale, kScreenW , 0.5) text:nil textFont:nil textColor:[UIColor colorWithRed:218.0/255.0 green:209.0/255.0 blue:179.0/255.0 alpha:0.5]];
    hengLineLab.backgroundColor = [UIColor colorWithRed:218.0/255.0 green:209.0/255.0 blue:179.0/255.0 alpha:1];
    [topOne addSubview:hengLineLab];

    //三个按钮
    UIButton *allBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, (183-64)*kscale, kScreenW/3, 52*kscale)];
    allBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [allBtn setTitleColor:[UIColor colorWithRed:64.0/255.0 green:46.0/255.0 blue:6.0/255.0 alpha:1] forState:UIControlStateNormal];
    [allBtn setTitle:@"全选" forState:UIControlStateNormal];
    [topOne addSubview:allBtn];
    
    UIButton *youBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreenW/3, (183-64)*kscale, kScreenW/3, 52*kscale)];
    youBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [youBtn setTitleColor:[UIColor colorWithRed:146.0/255.0 green:99.0/255.0 blue:.0/255.0 alpha:1] forState:UIControlStateNormal];
    [youBtn setTitle:@"优选计划" forState:UIControlStateNormal];
    [topOne addSubview:youBtn];
    
    UIButton *sanPostBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreenW/3*2, (183-64)*kscale, kScreenW/3, 52*kscale)];
    sanPostBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [sanPostBtn setTitleColor:[UIColor colorWithRed:64.0/255.0 green:46.0/255.0 blue:6.0/255.0 alpha:1] forState:UIControlStateNormal];
    [sanPostBtn setTitle:@"优选散标" forState:UIControlStateNormal];
    [topOne addSubview:sanPostBtn];
    return topView;
}
#pragma mark ---辅助放方法
//改变Label.Text后几位字符串大小
-(NSMutableAttributedString*) changeLabelWithText:(NSString*)needText
{
    
    NSMutableAttributedString *strAttribute = [[NSMutableAttributedString alloc] initWithString:needText];
    [strAttribute addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(needText.length - 1, 1)];
    return strAttribute;
}

- (UILabel *)createLabelWithFrame:(CGRect)frame text:(NSString *)text textFont:(UIFont *)font textColor:(UIColor *)color {
    
    UILabel * label = [[UILabel alloc] initWithFrame:frame];
    label.text = text;
    label.textColor = color;
    label.font = font;
    label.adjustsFontSizeToFitWidth = YES;
    label.textAlignment = NSTextAlignmentCenter;
    
    return label;
    
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.translucent = false;
    //    self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navtitlelogo"]];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"juxing"] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationItem.titleView.tintColor = [UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1];
//    self.navigationItem.leftBarButtonItem = [XDLMUIFactory createBBIWithImageStr:@"backblack" target:self action:@selector(letfBarClick)];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
